import { ScrollView, View, Text, Image } from '@tarojs/components';
import React, { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import { connect } from 'react-redux';
import './index.less';
import * as T from './types';
import actions from './actions';
import { store2Props } from './selectors';
import youImg from '@/assets/image/my/you.png';
import { setGlobalData } from '@/service/config';
import { cache } from 'config';

actions().actions.loadReducer();
// @ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class Index extends Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() { }

  componentDidShow() { }

  componentWillUnmount() {
    this.props.actions.clean();
  }

  async btnClick() {
    let iplanNotFirstIn = Taro.getStorageSync('iplanNotFirstIn')
    Taro.clearStorageSync();
    // ipland新人引导缓存不要清
    Taro.setStorageSync('iplanNotFirstIn', iplanNotFirstIn);
    setGlobalData('authInfo:token', null);
    setGlobalData(cache.LOGIN_DATA, null);
    Taro.showToast({
      icon: 'none',
      title: '退出登录成功',
    });
    setTimeout(() => {
      Taro.switchTab({
        url: '/pages/index/index',
      });
    }, 1000);
  }

  render() {
    return (
      <View className="packageCSetting">
        {/* <View
          className="wrap"
          onClick={() => {
            Taro.navigateTo({
              url: `/pages/package-A/message/index`,
            });
          }}
        >
          <View className="row">
            <Text className="textStyle">消息通知</Text>
          </View>
          <Image className="right" src={youImg} mode="widthFix" />
        </View> */}
        <View
          className="wrap"
          onClick={() => {
            Taro.navigateTo({
              url: '/pages/package-C/account/index',
            });
          }}
        >
          <View className="row">
            <Text className="textStyle">账号安全</Text>
          </View>
          <Image className="right" src={youImg} mode="widthFix" />
        </View>
        <View
          className="wrap"
          onClick={() => {
            Taro.navigateTo({
              url: '/pages/package-C/setting/feedback/index',
            });
          }}
        >
          <View className="row">
            <Text className="textStyle">建议反馈</Text>
          </View>
          <Image className="right" src={youImg} mode="widthFix" />
        </View>
        <View
          className="wrap"
          onClick={() => {
            Taro.navigateTo({
              url: '/pages/package-C/setting/about/index',
            });
          }}
        >
          <View className="row">
            <Text className="textStyle">关于我们</Text>
          </View>
          <Image className="right" src={youImg} mode="widthFix" />
        </View>
        <View className="bottom">
          <View className="btn_box">
            <Text
              className="btn-release"
              onClick={() => {
                this.btnClick();
              }}
            >
              退出登录
            </Text>
          </View>
        </View>
      </View>
    );
  }
}
